package com.itheima.d06_static_code_blocks;

/**
 * 猪类：猪的图纸/模板
 */
public class Pig {

    //成员属性/变量
    public String name;
    public int age;
    public static String owner;  //查询数据库获取：zhangsan/lisi/wangwu/zhaoliu
    public static String type;   //查询数据库获取：猪八戒/小花猪/小懒猪/小猪八戒

    public static String country;

    //构造方法
    public Pig() {
        System.out.println("无参构造方法");
    }


    //成员方法
    public void eat() {
        System.out.println("吃饭... ...");
    }

    //代码块
    static{
        System.out.println("连接mysql数据库");
        System.out.println("编写sql语句");
        System.out.println("发送sql语句");
        System.out.println("接收结果");
        System.out.println("处理结果");
        owner = "zhangsan";


        System.out.println("连接mysql数据库");
        System.out.println("编写sql语句");
        System.out.println("发送sql语句");
        System.out.println("接收结果");
        System.out.println("处理结果");
        type = "猪八戒";

        //静态代码块
        System.out.println("静态代码块");
        country = "中国";
    }

    {
        //实例代码块
        age = 1;
    }
}








